package com.shujia.bigdata.task;

import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Worker {

    /**
     * 接收端
     *
     * @param args
     */
    public static void main(String[] args) throws Exception {

        System.out.println("执行器以启动。。。。。");

        //绑定一个端口
        ServerSocket worker = new ServerSocket(8888);

        //等待被请求
        Socket accept = worker.accept();

        //获取直接输入流
        InputStream inputStream = accept.getInputStream();

        //构建对象输入流
        ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);

        //读取task线程对象
        Thread task = (Thread )objectInputStream.readObject();

        //启动线程
        task.start();

        objectInputStream.close();
        worker.close();


    }
}
